<template>
	<view class="main_form main">
		<view class="form_title">入库申请单详情</view>
		<view class="form_head">
			<view class="form_lable">申请单号：{{applyForm.applyForId}}</view>
			<view class="form_lable">使用仓库：{{applyForm.warehouse}}</view>
			<view class="form_lable">申请入库时间：{{applyForm.applyData}}</view>
			<view class="form_lable">申请人：{{applyForm.applyUser}}</view>
			<view class="form_lable">联系电话：{{applyForm.contactPhone}}</view>
			<view class="form_lable">创建时间:{{applyForm.create_time}}</view>
		</view>

		<view>
			<uni-table stripe emptyText="暂无更多数据" :loading="isloading">
				<uni-tr>
					<uni-th align="center">行</uni-th>
					<uni-th align="center">品名规格</uni-th>
					<uni-th align="center">单位</uni-th>
					<uni-th align="center">数量</uni-th>
					<uni-th align="center">验收类型</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in details" :key="index">
					<uni-td>{{ index + 1 }}</uni-td>
					<uni-td>{{ item.goodName }}-{{ item.spec.specStr }}</uni-td>
					<uni-td>{{ item.unit.unitName }}</uni-td>
					<uni-td>{{ item.quantity }}</uni-td>
					<uni-td>
					
						<view class="" v-for="(order, orderIndex) in item.batchOrder" :key="orderIndex">
							<view class="">{{ order.batchName }}</view>
						</view>
					</uni-td>
				</uni-tr>
			</uni-table>
		</view>
	</view>
</template>

<script>
const CloudDB = uniCloud.importObject('getDb');
export default {
	props: {
		applyForId: {
			type: String,
			default: '',
			required: true
		},
		applyForm:{
			type:Object,
			default:()=>{}
		}
	},
	name: 'applyForDetailView',
	data() {
		return {
			isloading: false,
			details: []
		};
	},
	async mounted() {
		await this.initData();
		console.log(JSON.stringify(this.applyForm));
	},
	methods: {
		async initData() {
			this.isloading = true;
			try {
				const res = await CloudDB.getDB('ApplyForGoodDetail', { applyForId: this.applyForId });
				if (res.code) {
					this.details = res.data;
				}
			} catch (e) {
				console.log(e);
			} finally {
				this.isloading = false;
			}
		}
	}
};
</script>

<style lang="scss" scoped>
@import '@/common/global.scss';
.form_head{
	display: flex;
	gap:20rpx;
}
.main{
	max-width:50% ;
}
.form_title{
	width: 100%;
	font-size: 40rpx;
	padding: 20rpx 20rpx;
	font-weight: 600;
	margin: 20rpx 20rpx;
}
.form_lable{
	padding: 10rpx 10rpx;
	border-radius: 8rpx;
	background-color: white;
}

</style>
